package com.zzx;

/**
 * @Author: zzx
 * @Date: 2025/6/2 21:23
 */
public enum RoleEnum {
    ADMIN("ADMIN", "管理员"),
    EMPLOYEE("EMPLOYEE", "普通员工");

    private final String code;
    private final String description;

    RoleEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static RoleEnum fromCode(String code) {
        for (RoleEnum role : RoleEnum.values()) {
            if (role.getCode().equals(code)) {
                return role;
            }
        }
        throw new IllegalArgumentException("Invalid role code: " + code);
    }
}
